/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUIComponents.Menu;

import MainClasses.main;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.*;

/**
 *
 * @author andrewcutler
 */
public class FileMenu extends JMenu{
    
    public FileMenu()
    {
        super("File");
    
        
        // Add the various menu items
        JMenuItem quit = new JMenuItem("Quit");
        quit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0)
            {
                main.exit(0);
            }
        });
        quit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_MASK));
                
        JMenuItem email = new JMenuItem("Email Assignments");
        email.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0)
            {
                
                main.getWeb().emailAssignments();
            }
        });
        
        JMenuItem about = new JMenuItem("About HomeworkManager v." + main.getPrefs().getVersionNumber());
        about.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent evt)
           {
               JOptionPane.showMessageDialog(null, "Version " + main.getPrefs().getVersionNumber() + "\n ©2007 Andrew Cutler", JOptionPane.MESSAGE_PROPERTY, JOptionPane.INFORMATION_MESSAGE);
           }
        });
        
        JMenuItem update = new JMenuItem("Update Assignments");
        update.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                main.updateAssignments();
            }
        });
        
        add(about);
        add(update);
        add(email);
        add(quit);
        
    }
}
